package com.sz.designpattern.behavior11.interpreter;

public class Test {
    public static void main(String[] args) {
        Calculator calculator = new Calculator();
        calculator.read("a = 1024");//读取表达式
        calculator.read("b = 512");
        System.out.println("a = 1024");
        System.out.println("b = 512");

        calculator.read("a + b");
        System.out.println("a + b = " + calculator.calculate());//计算结果
        calculator.read("a - b");
        System.out.println("a - b = " + calculator.calculate());
    }
}
